home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / C Internet Config / IC Application Source ƒ / IC Call Glue ƒ / IC Call Glue.c
Encoding:
Text File  |  1995-11-18  |  26.2 KB  |  601 lines  |  [TEXT/SPM ]

  1. o = kPascalStackBased
  2.         | RESULT_SIZE(kFourByteCode)
  3.         | STACK_ROUTINE_PARAMETER(1, kFourByteCode)
  4. };
  5.  
  6. /*
  7.     For an explanation of the inner workings of the following macros,
  8.     see the ICCFindConfigFile() function.
  9. */
  10.  
  11. /* A few macros to simplify the code (or does it make it more complex?  ;-) */
  12. #define CallComponentGlue(ptr) \
  13.     CallUniversalProc(CallComponentUPP,uppCallComponentProcInfo,(ptr))
  14.  
  15. #define PPC_Glue(parmsType) \
  16.     unsigned char flags; \
  17.     unsigned char size; \
  18.     short what; \
  19.     parmsType parms; \
  20.     internetConfigurationComponent inst
  21.  
  22. #define SetupGlue(var,sel,type,ic)\
  23.     (var).flags=0;\
  24.     (var).size=sizeof(type);\
  25.     (var).what=(sel);\
  26.     (var).inst=(ic)
  27.  
  28. #define PPC_VoidGlue \
  29.     unsigned char flags; \
  30.     unsigned char size; \
  31.     short what; \
  32.     internetConfigurationComponent inst
  33.  
  34. #define SetupVoidGlue(var,sel,ic)\
  35.     (var).flags=0;\
  36.     (var).size=0;\
  37.     (var).what=(sel);\
  38.     (var).inst=(ic)
  39.  
  40. #define SetGlueParm(var,ps,val) \
  41.     (var).parms.ps=(val)
  42.  
  43. /*
  44.     NOTE:
  45.     
  46.         For the PPC glue to work, the structures must be padded for 68k stacks.
  47.         
  48.         This means that everything must be padded on a word boundary.
  49.         
  50.         For types that are of odd number of bytes (i.e. char), you must add a
  51.         filler character after the type to pad it to a word.
  52.         
  53.         The list of types that need padding from the IC Types.h file are:
  54.         
  55.             (Booleans, chars, unsigned chars, ...)
  56.             ICPerm
  57. */
  58.  
  59. /*
  60.     ICCStartComponent
  61.     
  62.     PPC glue to call the component with the correct selector.
  63. */
  64. pascal ICError ICCStartComponent(internetConfigurationComponent inst, OSType creator){
  65.     ICError junk;
  66.     ICError err;
  67.  
  68. #pragma options align=mac68k
  69.     struct GlueParms {
  70.         OSType creator;
  71.     };
  72.     
  73.     typedef struct GlueParms GlueParms;
  74.     
  75.     struct ICCallGlue {
  76.         PPC_Glue(GlueParms);
  77.     };
  78.     
  79.     typedef struct ICCallGlue ICCallGlue;
  80. #pragma options align=reset
  81.     
  82.     ICCallGlue glue;
  83.     
  84.     if (inst==(internetConfigurationComponent)0) {
  85.         err = badComponentInstance;
  86.     } else {
  87.         SetupGlue(glue,kICCStart,GlueParms,inst);
  88.         
  89.         SetGlueParm(glue,creator,creator);
  90.         
  91.         err = CallComponentGlue(&glue);
  92.     }
  93.     
  94.     return err;
  95. }
  96.  
  97. /*
  98.     ICCStopComponent
  99.     
  100.     PPC glue to call the component with the correct selector.
  101. */
  102. pascal ICError ICCStopComponent(internetConfigurationComponent inst){
  103.     ICError err;
  104.     
  105. #pragma options align=mac68k
  106.     struct ICCallGlue {
  107.         PPC_VoidGlue;
  108.     };
  109.     
  110.     typedef struct ICCallGlue ICCallGlue;
  111. #pragma options align=reset
  112.     
  113.     ICCallGlue glue;
  114.     
  115.     SetupVoidGlue(glue,kICCStop,inst);
  116.     
  117.     err=CallComponentGlue(&glue);
  118.     
  119.     return err;
  120. }
  121.  
  122. /*
  123.     
  124.     PPC glue to call the component with the correct selector.
  125. */
  126. pascal ICError ICCFindConfigFile(internetConfigurationComponent inst, short count, ICDirSpecArrayPtr folders){
  127.     
  128. #pragma options align=mac68k
  129.     /*
  130.         For each of the glue routines, the GlueParms structure is defined.  It contains all of the parameters
  131.         required to call the component while passing the correct parameters.
  132.         
  133.         Note that the elements are listed in the reverse order of the parameters
  134.     */
  135.     struct GlueParms {
  136.         ICDirSpecArrayPtr folders;
  137.         short count;
  138.     };
  139.     
  140.     typedef struct GlueParms GlueParms;
  141.     
  142.     /*
  143.         Then the ICCallGlue structure is defined using the GlueParms structure to ensure the size
  144.         of the structure is set up correctly.
  145.     */
  146.     struct ICCallGlue {
  147.         PPC_Glue(GlueParms);
  148.     };
  149.     
  150.     typedef struct ICCallGlue ICCallGlue;
  151. #pragma options align=reset
  152.     
  153.     // A single variable named 'glue' is defined using the ICCallGlue type
  154.     ICCallGlue glue;
  155.     
  156.     // The glue variable is initialized using the selector, type, and instance of the component.
  157.     SetupGlue(glue,kICCFindConfigFile,GlueParms,inst);
  158.     
  159.     // Any parameters in the GlueParms structure are initialized
  160.     SetGlueParm(glue,folders,folders);
  161.     SetGlueParm(glue,count,count);
  162.     
  163.     // Call the componen UPP using a pointer to the glue variable.
  164.     return CallComponentGlue(&glue);
  165. }
  166.  
  167. /*
  168.     
  169.     PPC glue to call the component with the correct selector.
  170. */
  171. pascal ICError ICCFindUserConfigFile(internetConfigurationComponent inst, ICDirSpec *where){
  172. #pragma options align=mac68k
  173.     struct GlueParms {
  174.         ICDirSpec* where;
  175.     };
  176.     
  177.     typedef struct GlueParms GlueParms;
  178.     
  179.     struct ICCallGlue {
  180.         PPC_Glue(GlueParms);
  181.     };
  182.     
  183.     typedef struct ICCallGlue ICCallGlue;
  184. #pragma options align=reset
  185.     
  186.     ICCallGlue glue;
  187.     
  188.     SetupGlue(glue,kICCFindUserConfigFile,GlueParms,inst);
  189.     
  190.     SetGlueParm(glue,where,where);
  191.     
  192.     return CallComponentGlue(&glue);
  193. }
  194.  
  195. /*
  196.     
  197.     PPC glue to call the component with the correct selector.
  198. */
  199. pascal ICError ICCGeneralFindConfigFile(internetConfigurationComponent inst, Boolean search_prefs, Boolean can_create,
  200.         short count, ICDirSpecArrayPtr folders){
  201. #pragma options align=mac68k
  202.     struct GlueParms {
  203.         ICDirSpecArrayPtr folders;
  204.         short count;
  205.         Boolean can_create;
  206.         char filler1;
  207.         Boolean search_prefs;
  208.         char filler0;
  209.     };
  210.     
  211.     typedef struct GlueParms GlueParms;
  212.     
  213.     struct ICCallGlue {
  214.         PPC_Glue(GlueParms);
  215.     };
  216.     
  217.     typedef struct ICCallGlue ICCallGlue;
  218. #pragma options align=reset
  219.     
  220.     ICCallGlue glue;
  221.     
  222.     SetupGlue(glue,kICCGeneralFindConfigFile,GlueParms,inst);
  223.     
  224.     SetGlueParm(glue,search_prefs,search_prefs);
  225.     SetGlueParm(glue,filler1,0);
  226.     SetGlueParm(glue,filler0,0);
  227.     SetGlueParm(glue,can_create,can_create);
  228.     SetGlueParm(glue,count,count);
  229.     SetGlueParm(glue,folders,folders);
  230.     
  231.     return CallComponentGlue(&glue);
  232. }
  233.  
  234. /*
  235.     ICCChoseConfig
  236.     
  237.     PPC glue to call the component with the correct selector.
  238. */
  239. pascal ICError ICCChooseConfig(internetConfigurationComponent inst){
  240.     ICError err;
  241.     
  242. #pragma options align=mac68k
  243.     struct ICCallGlue {
  244.         PPC_VoidGlue;
  245.     };
  246.     
  247.     typedef struct ICCallGlue ICCallGlue;
  248. #pragma options align=reset
  249.     
  250.     ICCallGlue glue;
  251.     
  252.     SetupVoidGlue(glue,kICCChooseConfig,inst);
  253.     
  254.     err=CallComponentGlue(&glue);
  255.     
  256.     return err;
  257. }
  258.  
  259. /*
  260.     ICCChoseNewConfig
  261.     
  262.     PPC glue to call the component with the correct selector.
  263. */
  264. pascal ICError ICCChooseNewConfig(internetConfigurationComponent inst){
  265.     ICError err;
  266.     
  267. #pragma options align=mac68k
  268.     struct ICCallGlue {
  269.         PPC_VoidGlue;
  270.     };
  271.     
  272.     typedef struct ICCallGlue ICCallGlue;
  273. #pragma options align=reset
  274.     
  275.     ICCallGlue glue;
  276.     
  277.     SetupVoidGlue(glue,kICCChooseNewConfig,inst);
  278.     
  279.     err=CallComponentGlue(&glue);
  280.     
  281.     return err;
  282. }
  283.  
  284. /*
  285.     
  286.     PPC glue to call the component with the correct selector.
  287. */
  288. pascal ICError ICCGetConfigName(internetConfigurationComponent inst, Boolean longname,StringPtr name){
  289. #pragma options align=mac68k
  290.     struct GlueParms {
  291.         StringPtr name;
  292.         Boolean longname;
  293.         char filler;
  294.     };
  295.     
  296.     typedef struct GlueParms GlueParms;
  297.     
  298.     struct ICCallGlue {
  299.         PPC_Glue(GlueParms);
  300.     };
  301.     
  302.     typedef struct ICCallGlue ICCallGlue;
  303. #pragma options align=reset
  304.     
  305.     ICCallGlue glue;
  306.     
  307.     SetupGlue(glue,kICCGetConfigName,GlueParms,inst);
  308.     
  309.     SetGlueParm(glue,name,((StringPtr)name));
  310.     SetGlueParm(glue,longname,longname);
  311.     SetGlueParm(glue,filler,0);
  312.     
  313.     return CallComponentGlue(&glue);
  314. }
  315.  
  316. /*
  317.     
  318.     PPC glue to call the component with the correct selector.
  319. */
  320. pascal ICError ICCGetConfigReference(internetConfigurationComponent inst, ICConfigRefHandle ref){
  321. #pragma options align=mac68k
  322.     struct GlueParms {
  323.         ICConfigRefHandle ref;
  324.     };
  325.     
  326.     typedef struct GlueParms GlueParms;
  327.     
  328.     struct ICCallGlue {
  329.         PPC_Glue(GlueParms);
  330.     };
  331.     
  332.     typedef struct ICCallGlue ICCallGlue;
  333. #pragma options align=reset
  334.     
  335.     ICCallGlue glue;
  336.     
  337.     SetupGlue(glue,kICCGetConfigReference,GlueParms,inst);
  338.     
  339.     SetGlueParm(glue,ref,ref);
  340.     
  341.     return CallComponentGlue(&glue);
  342. }
  343.  
  344. /*
  345.     
  346.     PPC glue to call the component with the correct selector.
  347. */
  348. pascal ICError ICCSetConfigReference(internetConfigurationComponent inst, ICConfigRefHandle ref, long flags){
  349. #pragma options align=mac68k
  350.     struct GlueParms {
  351.         long flags;
  352.         ICConfigRefHandle ref;
  353.     };
  354.     
  355.     typedef struct GlueParms GlueParms;
  356.     
  357.     struct ICCallGlue {
  358.         PPC_Glue(GlueParms);
  359.     };
  360.     
  361.     typedef struct ICCallGlue ICCallGlue;
  362. #pragma options align=reset
  363.     
  364.     ICCallGlue glue;
  365.     
  366.     SetupGlue(glue,kICCSetConfigReference,GlueParms,inst);
  367.     
  368.     SetGlueParm(glue,flags,flags);
  369.     SetGlueParm(glue,ref,ref);
  370.     
  371.     return CallComponentGlue(&glue);
  372. }
  373.  
  374. /*
  375.     
  376.     PPC glue to call the component with the correct selector.
  377. */
  378. pascal ICError ICCSpecifyConfigFile(internetConfigurationComponent inst, FSSpec *config){
  379. #pragma options align=mac68k
  380.     struct GlueParms {
  381.         FSSpec* config;
  382.     };
  383.     
  384.     typedef struct GlueParms GlueParms;
  385.     
  386.     struct ICCallGlue {
  387.         PPC_Glue(GlueParms);
  388.     };
  389.     
  390.     typedef struct ICCallGlue ICCallGlue;
  391. #pragma options align=reset
  392.     
  393.     ICCallGlue glue;
  394.     
  395.     SetupGlue(glue,kICCSpecifyConfigFile,GlueParms,inst);
  396.     
  397.     SetGlueParm(glue,config,config);
  398.     
  399.     return CallComponentGlue(&glue);
  400. }
  401.  
  402. /*
  403.     
  404.     PPC glue to call the component with the correct selector.
  405. */
  406. pascal ICError ICCGetSeed(internetConfigurationComponent inst, long *seed){
  407. #pragma options align=mac68k
  408.     struct GlueParms {
  409.         long* seed;
  410.     };
  411.     
  412.     typedef struct GlueParms GlueParms;
  413.     
  414.     struct ICCallGlue {
  415.         PPC_Glue(GlueParms);
  416.     };
  417.     
  418.     typedef struct ICCallGlue ICCallGlue;
  419. #pragma options align=reset
  420.     
  421.     ICCallGlue glue;
  422.     
  423.     SetupGlue(glue,kICCGetSeed,GlueParms,inst);
  424.     
  425.     SetGlueParm(glue,seed,seed);
  426.     
  427.     return CallComponentGlue(&glue);
  428. }
  429.  
  430. /*
  431.     
  432.     PPC glue to call the component with the correct selector.
  433. */
  434. pascal ICError ICCGetPerm(internetConfigurationComponent inst, ICPerm *perm){
  435. #pragma options align=mac68k
  436.     struct GlueParms {
  437.         ICPerm* perm;
  438.     };
  439.     
  440.     typedef struct GlueParms GlueParms;
  441.     
  442.     struct ICCallGlue {
  443.         PPC_Glue(GlueParms);
  444.     };
  445.     
  446.     typedef struct ICCallGlue ICCallGlue;
  447. #pragma options align=reset
  448.     
  449.     ICCallGlue glue;
  450.     
  451.     SetupGlue(glue,kICCGetPerm,GlueParms,inst);
  452.     
  453.     SetGlueParm(glue,perm,perm);
  454.     
  455.     return CallComponentGlue(&glue);
  456.     
  457. }
  458.  
  459. /*
  460.     
  461.     PPC glue to call the component with the correct selector.
  462. */
  463. pascal ICError ICCBegin(internetConfigurationComponent inst, ICPerm perm){
  464. #pragma options align=mac68k
  465.     struct GlueParms {
  466.         ICPerm perm;
  467.         char filler0;
  468.     };
  469.     
  470.     typedef struct GlueParms GlueParms;
  471.     
  472.     struct ICCallGlue {
  473.         PPC_Glue(GlueParms);
  474.     };
  475.     
  476.     typedef struct ICCallGlue ICCallGlue;
  477. #pragma options align=reset
  478.     
  479.     ICCallGlue glue;
  480.     
  481.     SetupGlue(glue,kICCBegin,GlueParms,inst);
  482.     
  483.     SetGlueParm(glue,perm,perm);
  484.     SetGlueParm(glue,filler0,0);
  485.     
  486.     return CallComponentGlue(&glue);
  487. }
  488.  
  489. /*
  490.     
  491.     PPC glue to call the component with the correct selector.
  492. */
  493. pascal ICError ICCGetPref(internetConfigurationComponent inst,StringPtr key, ICAttr *attr, Ptr buf, long *size){
  494. #pragma options align=mac68k
  495.     struct GlueParms {
  496.         long* size;
  497.         Ptr buf;
  498.         ICAttr* attr;
  499.         StringPtr key;
  500.     };
  501.     
  502.     typedef struct GlueParms GlueParms;
  503.     
  504.     struct ICCallGlue {
  505.         PPC_Glue(GlueParms);
  506.     };
  507.     
  508.     typedef struct ICCallGlue ICCallGlue;
  509. #pragma options align=reset
  510.     
  511.     ICCallGlue glue;
  512.     
  513.     SetupGlue(glue,kICCGetPref,GlueParms,inst);
  514.     
  515.     SetGlueParm(glue,size,size);
  516.     SetGlueParm(glue,buf,buf);
  517.     SetGlueParm(glue,attr,attr);
  518.     SetGlueParm(glue,key,key);
  519.     
  520.     return CallComponentGlue(&glue);
  521. }
  522.  
  523. /*
  524.     
  525.     PPC glue to call the component with the correct selector.
  526. */
  527. pascal ICError ICCSetPref(internetConfigurationComponent inst,StringPtr key, ICAttr attr, Ptr buf, long size){
  528. #pragma options align=mac68k
  529.     struct GlueParms {
  530.         long size;
  531.         Ptr buf;
  532.         ICAttr attr;
  533.         StringPtr key;
  534.     };
  535.     
  536.     typedef struct GlueParms GlueParms;
  537.     
  538.     struct ICCallGlue {
  539.         PPC_Glue(GlueParms);
  540.     };
  541.     
  542.     typedef struct ICCallGlue ICCallGlue;
  543. #pragma options align=reset
  544.     
  545.     ICCallGlue glue;
  546.     
  547.     SetupGlue(glue,kICCSetPref,GlueParms,inst);
  548.     
  549.     SetGlueParm(glue,size,size);
  550.     SetGlueParm(glue,buf,buf);
  551.     SetGlueParm(glue,attr,attr);
  552.     SetGlueParm(glue,key,key);
  553.     
  554.     return CallComponentGlue(&glue);
  555. }
  556.  
  557. /*
  558.     
  559.     PPC glue to call the component with the correct selector.
  560. */
  561. pascal ICError ICCFindPrefHandle(internetConfigurationComponent inst,StringPtr key, ICAttr *attr, Handle prefh){
  562. #pragma options align=mac68k
  563.     struct GlueParms {
  564.         Handle prefh;
  565.         ICAttr* attr;
  566.         StringPtr key;
  567.     };
  568.     
  569.     typedef struct GlueParms GlueParms;
  570.     
  571.     struct ICCallGlue {
  572.         PPC_Glue(GlueParms);
  573.     };
  574.     
  575.     typedef struct ICCallGlue ICCallGlue;
  576. #pragma options align=reset
  577.     
  578.     ICCallGlue glue;
  579.     
  580.     SetupGlue(glue,kICCFindPrefHandle,GlueParms,inst);
  581.     
  582.     SetGlueParm(glue,attr,attr);
  583.     SetGlueParm(glue,prefh,prefh);
  584.     SetGlueParm(glue,key,key);
  585.     
  586.     return CallComponentGlue(&glue);
  587. }
  588.  
  589. /*
  590.     
  591.     PPC glue to call the component with the correct selector.
  592. */
  593. pascal ICError ICCGetPrefHandle(internetConfigurationComponent inst,StringPtr key, ICAttr *attr, Handle *prefh){
  594. #pragma options align=mac68k
  595.     struct GlueParms {
  596.         Handle* prefh;
  597.         ICAttr* attr;
  598.         StringPtr key;
  599.     };
  600.     
  601.     typedef struct GlueP